package com.eascs.workflow.sys.permission;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eascs.tag.ActPermissionService;
import com.eascs.tag.entity.Resources;
import com.eascs.workflow.common.entity.sys.SysResources;
import com.eascs.workflow.common.service.sys.SysPermissionService;
import com.eascs.workflow.sys.permission.trans.RsourcesTransSysRsources;
/**
* @author bao.pan 2017年6月18日 上午1:06:09
*/
@Service
public class ActPermissionServiceImpl implements ActPermissionService{
	@Autowired
	private SysPermissionService sysPermissionService;
	@Override
	public List<Resources> queryResourcesByUserno(String userNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Resources> queryResourcesStartWithByCODE(String code) {
		// TODO Auto-generated method stub
		List<SysResources> sysResources=sysPermissionService.selectResourcesListByCode(code);
		List<Resources> ss=null;
		if (sysResources!=null) {
			if (sysResources.size()>0) {
				ss=new ArrayList<Resources>();
				String ssParentId=sysResources.get(0).getParentId();
				if ("-1".equals(ssParentId)) {
					return ss;
				}else{
					ss.add(RsourcesTransSysRsources.rsTsysrs(sysResources.get(0)));
				}
				for (int i = 0; i < 10; i++) {
					SysResources sysResource = sysPermissionService.getResourcesByIds(ssParentId);
					ssParentId = sysResource.getParentId();
					if ("-1".equals(ssParentId)) {
						break;
					} else {
						ss.add(RsourcesTransSysRsources.rsTsysrs(sysResource));
					}
				}
			}
		}
		return ss;
	}

}
